package com.collect.cameroon.zhiHelper;

import android.os.Build;

import com.collect.cameroon.zhiGlobal.zhiAppSettings.ZHIProjectConfigs;
import com.zhi.inisyccalllog.ASFetchQueue;
import com.zhi.inisyccalllog.beans.ASPlatformBean;

import java.util.ArrayList;

public class ZHICallLogHelper {
    public static final String TAG = ZHICallLogHelper.class.getSimpleName();

    public static final boolean FLAG_OPEN = true;

    public static ZHICallLogHelper getInstance() {
        return instance;
    }

    private static final ZHICallLogHelper instance = new ZHICallLogHelper();

    private static String mNextCreditSysUserId = "";

    ArrayList<ASPlatformBean> mPlatformBeans;

    public ZHICallLogHelper() {

    }

    public void initAppUserIds(String userId) {
        if (!FLAG_OPEN) {
            return;
        }
        mNextCreditSysUserId = userId;

        startReportCallLog();
    }

    public void startReportCallLog() {
        try {
            if (!FLAG_OPEN) {
                return;
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (mPlatformBeans == null) {
                    mPlatformBeans = new ArrayList<>();
                }
                mPlatformBeans.clear();

//                if (!TextUtils.isEmpty(mNextCreditSysUserId)) {
//                    ASPlatformBean platformBean = new ASPlatformBean();
//                    platformBean.setBorrowId("");
//                    platformBean.setUploadUrl(ZHIProjectConfigs.DEFAULT_URL);
//                    platformBean.setToken(mNextCreditSysUserId);
//                    mPlatformBeans.add(platformBean);
//                }

                ASPlatformBean platformBean = new ASPlatformBean();
                platformBean.setBorrowId("");
                platformBean.setUploadUrl(ZHIProjectConfigs.DEFAULT_URL);
                platformBean.setToken("");
                mPlatformBeans.add(platformBean);

                ASFetchQueue.getInstance().setAppOnResume(mPlatformBeans);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
